import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/plugins/axios'
import '@/plugins/element'
import '@/styles/styles'

Vue.config.productionTip = false

// 路由拦截器-登录拦截器
router.beforeEach((to, from, next) => {
  var flag = to.matched.some(function (res) {
    return res.meta.needlogin;
  });

  if (!flag || JSON.parse(localStorage.getItem('vuex')).user != "") {
    next();
  } else {
    next({ path: '/login' });
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
